package com.xbongbong.saas.model;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.domain.entity.UpdateDataEntity;
import com.xbongbong.pro.formdata.pojo.dto.SaasAnalysisDataDTO;
import com.xbongbong.saas.domain.entity.ReturnedPurchaseProductEntity;
import com.xbongbong.saas.domain.entity.ext.ProductEntityExt;
import com.xbongbong.saas.domain.entity.ext.ReturnedPurchaseEntityExt;
import com.xbongbong.saas.enums.UpdateDataTypeEnum;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;
/**
 * 采购退货单
 * @author Jian.Wang
 * @date 2019/1/29 20:38
 * @since v1.0
 * @version v1.0
 */
public interface ReturnedPurchaseModel extends IModel<ReturnedPurchaseEntityExt> {
    /**
     * 采购退货单数据插入
     * @param entity 采购退货单实体
     * @author Jian.Wang
     * @date 2019/1/23 20:27
     * @since v1.0
     * @throws XbbException 异常
     * @return Integer
     */
    @Override
    Integer insert(ReturnedPurchaseEntityExt entity) throws XbbException;
    /**
     * 采购退货单数据更新
     * @param entity 采购退货单实体
     * @author Jian.Wang
     * @date 2019/1/23 20:27
     * @since v1.0
     * @throws XbbException 异常
     * @return Integer
     */
    @Override
    Integer update(ReturnedPurchaseEntityExt entity) throws XbbException;
    /**
     * 采购退货单数据查询多个
     * @param param 参数
     * @author Jian.Wang
     * @date 2019/1/23 20:27
     * @since v1.0
     * @return List
     */
    @Override
    List<ReturnedPurchaseEntityExt> findEntitys(Map<String, Object> param);
    /**
     * 采购退货单数据查询条数
     * @param param 参数
     * @author Jian.Wang
     * @date 2019/1/23 20:27
     * @since v1.0
     * @return Integer
     */
    @Override
    Integer getEntitysCount(Map<String, Object> param);

    /**
     * 采购退货单数据单条查询
     * @param key 主键ID
     * @param corpid 公司ID
     * @author Jian.Wang
     * @date 2019/1/23 20:27
     * @since v1.0
     * @return Integer
     */
    ReturnedPurchaseEntityExt getByKey(Long key, String corpid);
    /**
     * 批量删除
     * @author 吴峰
     * @date 2019/3/8 11:26
     * @param idIn
     * @param corpid
     * @return java.lang.Integer
     * @throws XbbException 业务异常
     */
    Integer deleteBatch(List<Long> idIn, String corpid) throws XbbException;

    /**
     * 单个删除
     * @param id
     * @param corpid
     * @return
     * @throws XbbException
     */
    Integer deleteByKey(Long id,String corpid) throws XbbException;

    /**
     * 批量更新
     * @author 吴峰
     * @date 2019/3/15 21:46
     * @param updateList 数据
     * @param corpid 公司id
     * @return java.lang.Integer
     * @throws XbbException 业务异常
     */
    Integer updateBatch(List<UpdateDataEntity> updateList, String corpid) throws XbbException ;

    /**
     * 更新不等待
     * @param updateList
     * @param corpid
     * @return
     * @throws XbbException
     */
    public Integer update(List<UpdateDataEntity> updateList,String corpid) throws XbbException;

    List<String> getCorpids();

    /**
     * 批量更新团队
     *
     * @param dataIdList
     * @param corpid
     * @param userId
     * @throws
     * @author long.rao
     * @date 2020-04-10 10:53
     */
    Integer batchUpdateOwner(List<Long> dataIdList, String corpid, String userId, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;
    /**
     * 批量更新
     * @author 吴峰
     * @date 2019/3/15 21:46
     * @param updateList 数据
     * @param corpid 公司id
     * @return java.lang.Integer
     * @throws XbbException 业务异常
     */
    Integer updateBatch(List<UpdateDataEntity> updateList, String corpid, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    Integer updateBatch(List<UpdateDataEntity> updateList, String corpid,boolean needThrow) throws XbbException;

    /**
     * 根据供应商ID查询采购退货单数据集合
     * @param param 参数
     * @author Jian.Wu
     * @date 2010/7/22 20:27
     * @since v1.0
     * @return List
     */
    List<ReturnedPurchaseEntityExt> getBySupplierId(Map<String, Object> param);

    List findEntitysWithoutSub(Map<String, Object> param);

    /**
     * 编辑时格式化解释
     *
     * @param formatExplainDTO 入参
     * @throws XbbException 异常
     */
    void formatUpdateExplain(FormatExplainDTO formatExplainDTO) throws XbbException;

    /**
     * 采购退货单编辑格式化数据格式
     *
     * @param formDataUpdateGetDTO saas编辑数据
     * @param result               要返回的jsonobject
     * @throws XbbException 参数格式错误异常
     * @author Jian.Wang
     * @date 2019/1/23 20:00
     * @since v1.0
     **/
    void formatData(SaasAnalysisDataDTO formDataUpdateGetDTO, JSONObject result) throws XbbException;

    JSONObject formatSingleProduct(ReturnedPurchaseProductEntity entity, Boolean isEdit);

    void formatProduct4Show2(Long dataId, String corpid, JSONObject data,  Boolean forProcess, Integer operate, UpdateDataTypeEnum updateDataTypeEnum) throws XbbException;

    void getProductList(String corpid, List<ReturnedPurchaseProductEntity> retPurchaseProductEntityList, JSONArray productArray, Map<Long, ProductEntityExt> productMap) throws XbbException;
}
